﻿namespace NKernel.Core.Impl
{
    using System.Reflection;

    /// <summary>
    /// Logical description of the various aspects of a component to be used in 
    /// the instantiation of the various interfaces and implementation.
    /// To be sure, a component can have more than one interface and 
    /// therefore, more than one implementation.
    /// </summary>
    public sealed class ComponentDescriptor
    {
        #region Fields

        private readonly Assembly assembly;
        private readonly string assemblyName;
        private readonly string componentImplementation;
        private readonly string componentInterface;
        private readonly string componentName;

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentDescriptor"/> class.
        /// </summary>
        /// <param name="componentName">Name of the component.</param>
        /// <param name="componentInterface">The component interface.</param>
        /// <param name="componentImplementation">The component implementation.</param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="assembly">The assembly.</param>
        public ComponentDescriptor(
            string componentName,
            string componentInterface,
            string componentImplementation, string assemblyName, Assembly assembly)
        {
            this.componentName = componentName;
            this.componentInterface = componentInterface;
            this.componentImplementation = componentImplementation;
            this.assemblyName = assemblyName;
            this.assembly = assembly;
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// Gets the assembly.
        /// </summary>
        /// <value>The assembly.</value>
        public Assembly Assembly
        {
            get { return assembly; }
        }

        /// <summary>
        /// Gets the name of the assembly.
        /// </summary>
        /// <value>The name of the assembly.</value>
        public string AssemblyName
        {
            get { return assemblyName; }
        }

        /// <summary>
        /// Gets the fully-qualified name of the class providing the component implementation.
        /// </summary>
        /// <value>The component implementation.</value>
        public string ComponentImplementation
        {
            get { return componentImplementation; }
        }

        /// <summary>
        /// Gets the fully qualified name of the class providing the component interface.
        /// </summary>
        /// <value>The component interface.</value>
        public string ComponentInterface
        {
            get { return componentInterface; }
        }

        /// <summary>
        /// Gets the name of the component.
        /// </summary>
        /// <value>The name of the component.</value>
        public string ComponentName
        {
            get { return componentName; }
        }

        /// <summary>
        /// Gets or sets the component file path.
        /// </summary>
        /// <value>The component path.</value>
        public string ComponentPath
        {
            get; set;
        }

        #endregion Properties
    }
}